CMAKE_MINIMUM_REQUIRED(VERSION 3.15)
option(BUILD_QDS_COMPONENTS "Build design studio components" ON)
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml Gui Widgets ShaderTools 3DCore 3DInput)    # 导入 Qt 模块


set(CMAKE_AUTOMOC ON)         # 设置Qt相关的变量，使CMake自动处理moc文件
set(CMAKE_AUTORCC ON)         # 资源文件处理
set(CMAKE_AUTOUIC ON)         # UI文件处理
set(CMAKE_INCLUDE_CURRENT_DIR ON)    # 包含当前目录


include_directories(${PROJECT_SOURCE_DIR}/include)      # 添加头文件，项目目录
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)       # 当前目录
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/test)       # 当前目录

file(GLOB_RECURSE SRC_LIST *.cpp *.h)


qt6_add_executable(${APP_NAME} ${SRC_LIST})   # 添加可执行文件
qt_finalize_executable(${APP_NAME})


target_link_libraries(${APP_NAME} PRIVATE     # 链接 Qt 库
    Qt6::Core
    Qt6::Quick
    Qt6::Qml
    Qt6::Gui
    Qt6::Widgets
    Qt6::3DCore
    Qt6::3DInput
    ${LIBRARY_NAME}
)

qt6_add_resources(${APP_NAME} "configuration"    # 添加资源文件
    PREFIX "/"
    FILES
        qtquickcontrols2.conf
)

set(QML_IMPORT_PATH ${QT_QML_OUTPUT_DIRECTORY}
    CACHE STRING "Import paths for Qt Creator's code model"
    FORCE
)

if (BUILD_QDS_COMPONENTS)
    include(${CMAKE_CURRENT_SOURCE_DIR}/qmlcomponents)
endif()

include(${CMAKE_CURRENT_SOURCE_DIR}/qmlmodules)


set(QML_IMPORT_PATH ${CMAKE_CURRENT_BINARY_DIR}/qml CACHE PATH    # make IDEs aware of the QML import path
    "Path to the custom QML components defined by the project")
